/**
 * @Copyright:Copyright (c) 1992 - 2015
 * @Company: TengTong
 */

package com.tengtong.duang.action.mapping;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.tengtong.duang.action.mapping.core.UrlHandler;
import com.tengtong.duang.web.commons.ClientRequestMethod;

/**
 * 一个 UrlHandler 列表，对应同一个 Url 但请求方法不同（Get,Post, Put, Delete)列表
 * 
 * @author mling
 *
 */
public class UrlHandlerMappingList {

	private final ConcurrentMap<ClientRequestMethod, UrlHandler> handlers = 
			new ConcurrentHashMap<>();
	
	/**
	 * 添加操作
	 * 
	 * @param method
	 * @param handler
	 * @return
	 */
	public UrlHandlerMappingList addUrlHandler(ClientRequestMethod method, UrlHandler handler){
		handlers.put(method, handler);
		
		return this;
	}

	/**
	 * 得到对应请求方法的处理器
	 * 
	 * @param method
	 * @return
	 */
	public UrlHandler findBy(ClientRequestMethod method) {
		return handlers.get(method);
	}
	
	
	
}
